% this script will split the large EDF data file into some small segments. 
% test OK.
% 
% @param
%   input none
%   output: some segmented data files placed on the disk
%
% @author zhangwei on 200801
% this script test the read/write of europe EDF format data file
% the script will split the large EDF format data file into smaller data
% blocks and then load each block into the memory.
%
% @attention
% Q: install of BioSig
% before you use the functions in this script, you must install the BioSig
% utility first. but it's a bit tricky to configure it.
% -> download BioSig from sourceforge
% -> extract it to \binx\research\biosig
%   you will see some directories
% -> start matlab 
% -> in matlab, 
%   cd \binx\research\biosig\biosig
% -> install
% -> ok.

cd D:\data\eeg-kul;
clear all;
pack;

%-------------------------------------------------------------------------
fullname = strcat( 'D:\data\eeg-kul\', 'f1.EDF' );
count = 1;
HDR = sopen(fullname, 'r');
while (~seof(HDR))
    [block,HDR] = sread(HDR, 3600); 
    size(block);
    segfile = ['f1' '_segment' int2str(count) 'hr.mat'];
    segfile
    save( segfile, 'block' );
    count = count + 1;
end
HDR = sclose(HDR);

clear all;
pack;

%-------------------------------------------------------------------------
fullname = strcat( 'D:\data\eeg-kul\', 'f34.EDF' );
count = 1;
HDR = sopen(fullname, 'r');
while (~seof(HDR))
    [block,HDR] = sread(HDR, 3600); 
    size(block);
    segfile = ['f34' '_segment' int2str(count) 'hr.mat'];
    segfile
    save( segfile, 'block' );
    count = count + 1;
end
HDR = sclose(HDR);

